<?php

	echo "<pre>";
	require_once 'singletonPDO.php';
	$pdo = singletonPDO::getPdo();
	$pdo -> exec('set names utf8');

	//（1）prepare & execute
	//半成品sql语句
	//只能由prepare 预处理语句执行
	// $sql = "insert into user values(?,?,?)";
	// $halfPro = $pdo->prepare($sql);
	// //将半成品通过execute方法传入参数，变成成品
	// $result = $halfPro->execute(['','xiaoming','666']);

	

	//（2）bindColumn
	$sql = "select * from user where 1";
	$halfPro = $pdo->prepare($sql);
	$halfPro->execute();

	//将结果中的内容绑定再指定变量上
	$halfPro->bindColumn(1,$uid);
	$halfPro->bindColumn(2,$uname);
	$halfPro->bindColumn(3,$upass);

	//读取检索结果
	$info = [];
	for($i=0; $row=$halfPro->fetch(PDO::FETCH_COLUMN); $i++){
		$info[$i] = array('id'=>$uid,'userName' => $uname, 'password'=>$upass);
	}
	var_dump($info);

?>